package sctu.edu.java.year2016.team07.shihaocheng.day20160522.Chapter6_2;

import java.util.Scanner;

/**
 * Created by admin on 2016/5/22.
 *只用for循环和if语句除去空格
 */
public class chapter6_2 {
    public static void main(String[] args) {
        char[] a = new char[100];
        String str;
        char c = ' ';
        int p=0;
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入字符串：");
        str = sc.nextLine();
        System.out.println();
        for (int i = 0; i < str.length(); i ++)
        {
            if(str.charAt(i) == c)
            {
                i++;
            }

            a[i] = str.charAt(i);


            System.out.print(""+a[i]);
        }

    }
}
